import Vue from 'vue'
import VueRouter from 'vue-router'

Vue.use(VueRouter)

const routes = [
  {
    path: '/',
    redirect: '/main'
  },
  {
    path: '/main',
    name: 'Main',
    component: () => import('@/views/client/layout/MainView.vue'),
    children: [
      {
        path: '',
        redirect: '/home'
      },
      {
        path: '/home',
        name: 'Home',
        component: () => import('@/views/client/layout/HomeView.vue')
      },
      {
        path: '/courseVideo',
        name: 'CourseVideo',
        component: () => import('@/views/client/course/CourseVideoView.vue')
      },
      {
        path: '/courseVideo/detail/:id',
        name: 'CourseVideoDetail',
        component: () =>
          import('@/views/client/course/CourseVideoDetailView.vue'),
        props: true
      },
      {
        path: '/courseBook',
        name: 'CourseBook',
        component: () => import('@/views/client/course/CourseBookView.vue')
      },
      {
        path: '/courseBook/detail/:id',
        name: 'CourseBookDetail',
        component: () =>
          import('@/views/client/course/CourseBookDetailView.vue'),
        props: true
      },
      {
        path: '/bbs',
        name: 'Bbs',
        component: () => import('@/views/client/post/PostView.vue')
      },
      {
        path: '/bbs/detail/:id',
        name: 'BbsDetail',
        component: () => import('@/views/client/post/PostDetailView.vue'),
        props: true
      },
      {
        path: '/testQuestion',
        name: 'TestQuestion',
        component: () => import('@/views/client/test/TestQuestionView.vue')
      },
      {
        path: '/testExam/:testExamId/:examTime/:testCategoryId/:testExamName',
        name: 'TestExam',
        component: () => import('@/views/client/test/TestExamView.vue'),
        props: true
      },
      {
        path: '/exam',
        name: 'Exam',
        component: () => import('@/views/client/test/ExamView.vue')
      },
      {
        path: '/exam/detail/:id',
        name: 'ExamDetail',
        component: () => import('@/views/client/test/ExamDetailView.vue'),
        props: true
      },
      {
        path: '/about/notice',
        name: 'AboutNotice',
        component: () => import('@/views/client/about/NoticeView.vue')
      },
      {
        path: '/user',
        name: 'User',
        redirect: '/user/info',
        component: () => import('@/views/client/user/UserView.vue'),
        children: [
          {
            path: '/user/info',
            name: 'UserInfo',
            component: () => import('@/views/client/user/UserInfoView.vue')
          },
          {
            path: '/user/edit',
            name: 'UserEdit',
            component: () => import('@/views/client/user/UserEditView.vue')
          },
          {
            path: '/user/post',
            name: 'UserPost',
            component: () => import('@/views/client/user/UserPostView.vue')
          },
          {
            path: '/user/exam',
            name: 'UserExam',
            component: () => import('@/views/client/user/UserExamView.vue')
          },
          {
            path: '/user/collect',
            name: 'UserCollect',
            component: () => import('@/views/client/user/UserCollectView.vue')
          }
        ]
      }
    ]
  },
  {
    path: '/admin',
    name: 'Admin',
    component: () => import('@/views/admin/layout/AdminLayoutView.vue'),
    children: [
      {
        path: '',
        redirect: '/admin/welcome'
      },
      {
        path: '/admin/welcome',
        name: 'AdminWelcome',
        component: () => import('@/views/admin/layout/WelcomeView.vue')
      },
      {
        path: '/admin/adminManage',
        name: 'AdminAdminManage',
        component: () => import('@/views/admin/user/AdminView.vue')
      },
      {
        path: '/admin/editAdmin/:id',
        name: 'AdminEditAdmin',
        component: () => import('@/views/admin/user/EditAdminView.vue'),
        props: true
      },
      {
        path: '/admin/userManage',
        name: 'AdminUserManage',
        component: () => import('@/views/admin/user/UserView.vue')
      },
      {
        path: '/admin/editUser/:id',
        name: 'AdminEditUser',
        component: () => import('@/views/admin/user/EditUserView.vue'),
        props: true
      },
      {
        path: '/admin/courseCategory',
        name: 'AdminCourseCategory',
        component: () => import('@/views/admin/course/CourseCategoryView.vue')
      },
      {
        path: '/admin/editCourseCategory/:id',
        name: 'AdminEditCourseCategory',
        component: () =>
          import('@/views/admin/course/EditCourseCategoryView.vue'),
        props: true
      },
      {
        path: '/admin/courseVideo',
        name: 'AdminCourseVideo',
        component: () => import('@/views/admin/course/CourseVideoView.vue')
      },
      {
        path: '/admin/editCourseVideo/:id',
        name: 'AdminEditCourseVideo',
        component: () => import('@/views/admin/course/EditCourseVideoView.vue'),
        props: true
      },
      {
        path: '/admin/courseBook',
        name: 'AdminCourseBook',
        component: () => import('@/views/admin/course/CourseBookView.vue')
      },
      {
        path: '/admin/editCourseBook/:id',
        name: 'AdminEditCourseBook',
        component: () => import('@/views/admin/course/EditCourseBookView.vue'),
        props: true
      },
      {
        path: '/admin/testCategory',
        name: 'AdminTestCategory',
        component: () => import('@/views/admin/test/TestCategoryView.vue')
      },
      {
        path: '/admin/editTestCategory/:id',
        name: 'AdminEditTestCategory',
        component: () => import('@/views/admin/test/EditTestCategoryView.vue'),
        props: true
      },
      {
        path: '/admin/testExam',
        name: 'AdminTestExam',
        component: () => import('@/views/admin/test/TestExamView.vue')
      },
      {
        path: '/admin/editTestExam/:examName/:id',
        name: 'AdminEditTestExam',
        component: () => import('@/views/admin/test/TestExamTopicView.vue'),
        props: true
      },
      {
        path: '/admin/:examName/editTestExamTopic/:testExamId/:id',
        name: 'AdminEditTestExamTopic',
        component: () => import('@/views/admin/test/EditTestExamTopicView.vue'),
        props: true
      },
      {
        path: '/admin/examRecord',
        name: 'AdminExamRecord',
        component: () => import('@/views/admin/test/ExamRecordView.vue')
      },
      {
        path: '/admin/examDetail/:id',
        name: 'AdminExamDetail',
        component: () => import('@/views/admin/test/ExamDetailView.vue'),
        props: true
      },
      {
        path: '/admin/postManage',
        name: 'AdminPostManage',
        component: () => import('@/views/admin/post/PostView.vue')
      },
      {
        path: '/admin/editPost/:id',
        name: 'AdminEditPost',
        component: () => import('@/views/admin/post/EditPostView.vue'),
        props: true
      },
      {
        path: '/admin/postRemark/:id',
        name: 'AdminPostRemark',
        component: () => import('@/views/admin/post/PostRemarkView.vue'),
        props: true
      },
      {
        path: '/admin/noticeManage',
        name: 'AdminNoticeManage',
        component: () => import('@/views/admin/about/NoticeView.vue')
      },
      {
        path: '/admin/editNotice/:id',
        name: 'AdminEditNotice',
        component: () => import('@/views/admin/about/EditNoticeView.vue'),
        props: true
      },
      {
        path: '/admin/bannerManage',
        name: 'AdminBannerManage',
        component: () => import('@/views/admin/about/BannerView.vue')
      },
      {
        path: '/admin/remarkManage/:type/:id',
        name: 'AdminRemarkManage',
        component: () => import('@/views/admin/course/CourseRemarkView.vue'),
        props: true
      }
    ]
  },
  {
    path: '/admin/login',
    name: 'AdminLogin',
    component: () => import('@/views/admin/login/AdminLoginView.vue')
  },
  {
    path: '/login',
    name: 'Login',
    component: () => import('@/views/client/login/UserLoginView.vue')
  }
]

const router = new VueRouter({
  // mode: 'history',
  routes
})

export default router
